﻿using System.Collections.Generic;
using Autofac;

namespace Messhall.Framework.Autofac;

public class AutofacBuilder
{
    private static IContainer Container { get; set; } = null;

    /// <summary>
    /// 方法注入
    /// </summary>
    public static void SetContainer(IContainer container)
    {
        Container = container;
    }

    /// <summary>
    /// 获取全部注册
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static T Resolve<T>()
    {
        return Container.Resolve<T>();
    }

    /// <summary>
    /// 获取全部注册
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static IEnumerable<T> ResolveAll<T>()
    {
        return Container.Resolve<IEnumerable<T>>();
    }
}